package com.easy;

/**
 * Created by Lxk on 2019/5/17.
 */
public class Solution557 {

    public String reverseWords(String s) {
        if(s == null){
            return null;
        }
        StringBuffer sb = new StringBuffer();
        String[] arr = s.split(" ");
        for(String str : arr){
            if("".equals(str)){
                continue;
            }else{
                sb.append(reverseSingleWord(str) + " ");
            }
        }

        return sb.toString().trim();
    }

    public String reverseSingleWord(String words){
        StringBuffer sb = new StringBuffer();
        for(int i = words.length()-1;i >= 0;i--){
            sb.append(words.charAt(i));
        }
        return sb.toString();
    }

}
